package jwdt.xadmin.flow.action;

import org.snaker.engine.access.Pager;
import org.snaker.engine.access.QueryFilter;
import org.snaker.engine.entity.Surrogate;

import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

/**
 * 委托授权
 */
@Controller("/xadmin/flow")
public class SurrogateAction extends SnakerAction {
	@RequestMapping("/surrogateList")
	public Page doList(Form f, Module m) {
		Pager<Surrogate> page = new Pager<Surrogate>();
		page.setPageNo(f.getInt("pageNo", 1));
		searchSurrogate(page, new QueryFilter());
		f.add("page", page);
		return m.jspPage(url.concat("surrogateList.jsp"));
	}
	
	@RequestMapping("/surrogateAdd")
	public Page doAdd(Form f, Module m) {
		f.add("processNames", getAllProcessNames());
		return m.jspPage(url.concat("surrogateAdd.jsp"));
	}
	
	@RequestMapping("/surrogateEdit")
	public Page doEdit(Form f, Module m) {
		Surrogate surrogate = getSurrogate(f.getString("id"));
		f.add("surrogate", surrogate);
		f.add("processNames", getAllProcessNames());
		return m.jspPage(url.concat("surrogateEdit.jsp"));
	}
	
	@RequestMapping("/surrogateView")
	public Page doView(Form f, Module m) {
		f.add("surrogate", getSurrogate(f.getString("id")));
		return m.jspPage(url.concat("surrogateView.jsp"));
	}
	
	@RequestMapping("/surrogateSave")
	public Page doSave(Form f, Module m) {
		Surrogate model = (Surrogate)f.copy2Class(Surrogate.class);
		addSurrogate(model);
		return m.redirectPage(url.concat("surrogateList.do"));
	}
	
	@RequestMapping("/surrogateUpdate")
	public Page doUpdate(Form f, Module m) {
		Surrogate model = (Surrogate)f.copy2Class(Surrogate.class);
		addSurrogate(model);
		return m.redirectPage(url.concat("surrogateList.do"));
	}
	
	@RequestMapping("/surrogateDelete")
	public Page doDelete(Form f, Module m) {
		deleteSurrogate(f.getString("id"));
		return m.redirectPage(url.concat("surrogateList.do"));
	}
}
